package cn.mw.cmdb.controller;

import cn.mw.cmdb.mongoMapper.InstanceInfoMapper;
import cn.mw.cmdb.service.impl.CmdbServiceManage;
import cn.mw.microMonitorCommon.api.cmdb.AssetsService;
import cn.mw.microMonitorCommon.api.common.BaseApiService;
import cn.mw.microMonitorCommon.api.common.ResponseBase;
import cn.mw.microMonitorCommon.api.scan.AssetScanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RequestMapping("/test")
@RestController
@Api(value = "验证")
@Slf4j
public class TestController extends BaseApiService {

    @Autowired
    private CmdbServiceManage cmdbServiceManage;

    @Autowired
    private InstanceInfoMapper instanceInfoMapper;

    @DubboReference(check = false, timeout = 120000,group = "collect")
    private AssetScanService assetScanService;

//    @Autowired
//    private DataLakeSyncServiceImpl dataLakeSyncService;

    @DubboReference(check = false, timeout = 120000)
    private AssetsService assetsService;

    @PostMapping("/testZabbix")
    @ResponseBody
    @ApiOperation(value = "zabbix验证")
    public ResponseBase<Object> addSceneTemplate(@RequestBody Map<String,Object> params) throws Exception {
        // 查询所有运维监控基础模型
//        CustomModelServiceImpl service = (CustomModelServiceImpl) cmdbServiceManage.getModelService(CustomModelServiceImpl.ID);
//        SearchParam searchParam = new SearchParam();
//        searchParam.addSubCondition(CMDBTool.getFieldName(ModelInfo::getFunctionModule)
//                , new SubCondition(CriteriaOpsType.in.name(), FunctionModuleEnum.enableMonitor.getCode()));
//        List<ModelInfo> modelInfos = service.doSelectNormalModelList(searchParam);
//        dataLakeSyncService.syncData(JSON.parseObject(JSON.toJSONString(params), DataLakeConfig.class));
        assetsService.recoverInstanceMonitorStatus(params.get("instanceId").toString());
        return null;
    }


}
